#-*- coding:utf-8 -*-
import numpy
from pylab import *
import matplotlib.pyplot as plt
import datetime

class CSV():
    def read(self, path_string):
        csv_raw_data = numpy.loadtxt(path_string, dtype = 'string', delimiter = ',', usecols = None)
        return csv_raw_data

class X_TIME_Y_SET():
    def list_plot(self, raw_data, y_axis_column_number, color_str):
        x_axis_time_list = []
        y_axis_parameter_list = []
        data_sum_column_number = len(raw_data)-1
        start_time = raw_data[1][0]
        start_time = datetime.datetime.strptime(start_time, "%H:%M:%S")
        one_second_del = datetime.timedelta(seconds = 1)
        for row_number in range(2, data_sum_column_number+1):
            this_parameter = raw_data[row_number][y_axis_column_number]
            if this_parameter != "" and this_parameter !='XXXXX':
                this_time = start_time + one_second_del * (row_number -2)
                x_axis_time_list.append(this_time)
                y_axis_parameter_list.append(int(raw_data[row_number][y_axis_column_number]))
        x_axis_time_list = matplotlib.dates.date2num(x_axis_time_list)
        plot(x_axis_time_list, y_axis_parameter_list, color = color_str, label = raw_data[0][y_axis_column_number])



csv = CSV()
path = "LRRA_MODEL.csv"
data = csv.read(path)

x_time_y_set = X_TIME_Y_SET()

x_time_y_set.list_plot(data, 1, 'green')
x_time_y_set.list_plot(data, 2, 'blue')


plt.subplots_adjust(bottom=0.2)
plt.xticks( rotation=25 )
ax=plt.gca()
xfmt = matplotlib.dates.DateFormatter('%H:%M:%S')
ax.xaxis.set_major_formatter(xfmt)

plt.xlabel('LRRA-time')
plt.grid(True)
legend()
show()